﻿using System;
using System.ComponentModel;
using WPFLocalizeExtension.Engine;

namespace Core.Localization.Attributes
{
    [AttributeUsage(AttributeTargets.Property)]
    public class LocalizableCategoryAttribute : CategoryAttribute
	{
		public LocalizableCategoryAttribute(string assembly, string resourceDictionary, string localizableValue)
            : base(Localize(assembly, resourceDictionary, localizableValue))
		{
		}

        private static string Localize(string assembly, string resourceDictionary, string localizableValue)
        {
			object localized = LocalizeDictionary.Instance.GetLocalizedObject(assembly, resourceDictionary, localizableValue, LocalizeDictionary.CurrentCulture);
			return localized != null ? localized.ToString() : localizableValue;
        }
	}
}